<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"  
                xmlns:h="http://java.sun.com/jsf/html"  
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./../templates/StaffTemplate.xhtml">

    <ui:define name="nav_menu">
        <p:menubar model="#{staffChangeInitialPasswordManagedBean.staffMenuModel}"/>
    </ui:define>
    <ui:define name="content"> 
        <h1>View point redemptions in a specified period of time</h1>         
        <p:fieldset>
            <h:outputText value="Specify the period of time : " />
            <h:panelGrid id="display" columns="2" cellpadding="5">  
                <h:outputText value="From : " />  
                <p:calendar value="#{tCubeULPManagerBean.inputDateFrom}" />   
                <h:outputText value="Until : " />  
                <p:calendar value="#{tCubeULPManagerBean.inputDateUntil}" />
                <p:commandButton value="View" actionListener="#{tCubeULPManagerBean.retrieveRedemptionInPeriodList}" />
                <p:commandButton value="View All Redemptions" actionListener="#{tCubeULPManagerBean.retrieveAllRedemptionList}" />
            </h:panelGrid>         
        </p:fieldset>
        <br/>
        <br/>
        <p:panel rendered="#{tCubeULPManagerBean.displayRedemptions}">
            <p:accordionPanel autoHeight="false" >
                <p:tab title="View Redemptions (Double click to select) ">
                    <p:dataTable var="redemption" value="#{tCubeULPManagerBean.redemptionInPeriodList}" paginator="true" 
                                 rows="10" emptyMessage="No redemption found" selection="#{tCubeULPManagerBean.selectedRedemption}" 
                                 selectionMode="single" rowSelectListener="#{tCubeULPManagerBean.onRowSelectNavigateViewRedemption}"
                                 dblClickSelect="true">

                        <p:column sortBy="#{redemption.id}" filterBy="#{redemption.id}">
                            <f:facet name="header">
                                <h:outputText value="ID" />
                            </f:facet>
                            <h:outputText value="#{redemption.id}" />
                        </p:column>

                        <p:column sortBy="#{redemption.referenceNumber}" filterBy="#{redemption.referenceNumber}">
                            <f:facet name="header">
                                <h:outputText value="Reference Number" />
                            </f:facet>
                            <h:outputText value="#{redemption.referenceNumber}" />
                        </p:column>

                        <p:column sortBy="#{redemption.dateCreated}" filterBy="#{redemption.dateCreated}">
                            <f:facet name="header">
                                <h:outputText value="Redemption Date" />
                            </f:facet>
                            <h:outputText value="#{redemption.dateCreated}">
                                <f:convertDateTime dateStyle="full" pattern="EEE, dd/MM/yyyy" timeZone="EST" type="date" />
                            </h:outputText>
                        </p:column>

                        <p:column sortBy="#{redemption.dateExpired}" filterBy="#{redemption.dateExpired}">
                            <f:facet name="header">
                                <h:outputText value="Expiry Date" />
                            </f:facet>
                            <h:outputText value="#{redemption.dateExpired}">
                                <f:convertDateTime dateStyle="full" pattern="EEE, dd/MM/yyyy" timeZone="EST" type="date" />
                            </h:outputText>
                        </p:column>

                        <p:column sortBy="#{redemption.redemptionList.pointsToRedeem}" filterBy="#{redemption.redemptionList.pointsToRedeem}">
                            <f:facet name="header">
                                <h:outputText value="Points Used" />
                            </f:facet>
                            <h:outputText value="#{redemption.redemptionList.pointsToRedeem} points" />
                        </p:column>

                        <p:column sortBy="#{customerULPManagerBean.returnRedemptionStatus(redemption.dateUsed==null)}" filterBy="#{customerULPManagerBean.returnRedemptionStatus(redemption.dateUsed==null)}">
                            <f:facet name="header">
                                <h:outputText value="Status" />
                            </f:facet>
                            <h:outputText value="#{customerULPManagerBean.returnRedemptionStatus(redemption.dateUsed==null)}" />
                        </p:column>
                    </p:dataTable>
                </p:tab>
            </p:accordionPanel> 
        </p:panel>
    </ui:define>
</ui:composition>